package com.hd.trans.network.bean.aiChat

import android.util.ArrayMap
import com.hd.trans.network.ParamUtils
import com.hd.trans.network.bean.UserInfoBean
import com.hd.trans.share.ConvertObjectToMap
import okhttp3.RequestBody

data class AiChatTaskRequest(
    val prompt: String,
    val system: String? = null,
    val history: MutableList<String>? = null,
    var strict: Int = 0,//文本检测严格模式,用于上架审核等情况，0：非严格模式，1：严格模式
    var limit: Int = 0, //是否开启对用户的使用次数受后台预设限制. 0:关闭,1:开启, 默认:0
    var model: String = "32k",//AI模型, 默认:32k, 可选: 32k,128k,256k,deepseek,deepseekv3, 推荐使用deepseek, deepseekv3速度快没有深度思考
){
    fun makeRequestBody(userinfoBean: UserInfoBean?): RequestBody {
        val params = ParamUtils.createAiTransParams(ArrayMap<String, Any>().apply {
            if (history.isNullOrEmpty()){
                put("history", "[]")
            }else{
                put("history", ParamUtils.toJson(history))
            }
            system?.let {
                put("system", it)//更多设置：你来自韩国，你只会用韩语回答
            }
            put("prompt", prompt.trim())//输入内容前后不能有空格，否则会报签名有误。

            if(strict != 0 && strict != 1){
                strict = 0
            }
            put("strict", strict)

            if(model != "32k" && model!= "128k" && model!= "256k" && model!= "deepseek" && model!= "deepseekv3"){
                model = "32k"
            }
            put("model", model)
        }, userinfoBean)
        return params
    }

    fun toRequestBody(): RequestBody {
        return ConvertObjectToMap.toRequestBody(this)
    }
}
